package com.core.controller;

import com.core.vo.OperationLogVo;
import com.core.annotation.OperationLog;
import com.core.domain.OperationLogs;
import com.core.resp.AjaxResponse;
import com.core.resp.PageResult;
import com.core.service.OperationLogService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @author : HUANG
 * @create : 2025/6/1 16:28
 * @function : 操作日志控制器
 */
@RestController
@RequestMapping("/operation-log")
@Api("操作日志管理")
public class OperationLogController {

    private static final Logger log = LoggerFactory.getLogger(OperationLogController.class);
    @Autowired
    private OperationLogService operationLogService;

    @PreAuthorize("@ss.hasAuthority('operation_log:list')")
    @PostMapping("/get/page/{pageSize}/{pageNum}")
    @OperationLog(type = "list", module = "operation_log", description = "分页获取操作日志列表")
    public AjaxResponse getLogsPage(@PathVariable Long pageSize, @PathVariable Long pageNum, @RequestBody(required = false) OperationLogs query) {
        try {
            PageResult<OperationLogVo> result = operationLogService.selectPage(pageSize, pageNum, query);
            return AjaxResponse.success(200, "查询成功", result);
        } catch (Exception e) {
            return AjaxResponse.error(500, "获取操作日志列表失败: " + e.getMessage());
        }
    }
} 